<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/1/31
 * Time: 12:43
 */

defined('BASEPATH') OR exit('No direct script access allowed');

class Sys_message
{

    public $message = '';
    
    public $data = array();

    public $status = '';

    public function wrong($message)
    {
        $this->message = $message;
        $this->status = 'error';
        $this->export_json();
    }

    public function success($message, $data = array())
    {
        $this->message = $message;
        $this->data = $data;
        $this->status = 'success';
        $this->export_json();
    }

    public function warning($message)
    {
        $this->message = $message;
        $this->status = 'warning';
        $this->export_json();
    }

    public function export_json()
    {
        $data = array(
            'info' => $this->message,
            'data' => $this->data,
            'status' => $this->status
        );

        die(json_encode($data));
    }
}